package com.itheima;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 王同学
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult {
   // private String host;
   // private String errorMessage;
    private Integer code;

    private String msg;

    private Object data;

    private Long total;

    public CommonResult(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;

    }

    public static CommonResult success() {
        return new CommonResult(1, "成功", null);
    }

    public static CommonResult success(String msg) {
        return new CommonResult(200, msg, null);
    }

    public static CommonResult success(String msg, Object date) {
        return new CommonResult(200, msg, date);
    }

    public static CommonResult success(Object data) {
        return new CommonResult(200, "成功", data);
    }

    public static CommonResult error(String msg) {
        return new CommonResult(0, msg, null);
    }

    public static CommonResult error(int code, String msg, Object data) {
        return new CommonResult(code, msg, data);
    }

    public static CommonResult success(int code, String msg, Object data) {
        //传上来三个值
        return new CommonResult(code, msg, data);
    }

    public static CommonResult list(Object data, Long total) {
        //计算个数的
        return new CommonResult(200, "成功", data, total);
    }
}
